import request from '@/utils/request'

export const getRoleListApi = (params) => {
  return request.get('/sys/role', { params })
}

export const getAddRoleApi = (data) => {
  return request.post('/sys/role', data)
}

export const updateRoleApi = (data) => {
  return request.put(`/sys/role/${data.id}`, data)
}

export const delRoleApi = (id) => {
  return request.delete(`/sys/role/${id}`)
}

/**
 * 在员工中获取角色
 * 获取可用的角色
 * 这是获取角色
 * **/

export const getEnableRoleListApi = () => {
  return request.get('/sys/role/list/enabled')
}

/**
 * 分配员工角色
 * 这是分配角色
 * ***/

export const assignRoleApi = (data) => {
  return request.put('/sys/user/assignRoles', data)
}

/**
 * 获取角色详情 === 想从中拿到该角色已经分配好的权限
 * **/

export const getRoleDetailApi = (id) => {
  return request.get(`/sys/role/${id}`)
}

/**
 * 给角色分配权限
 *
 * ***/

export const assignPermApi = (data) => {
  return request.put('/sys/role/assignPrem', data)
}
